package com.fxb.learn.direct_buff.byte_buffer;

import lombok.extern.slf4j.Slf4j;

import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;

/**
 * @author fangjiaxiaobai
 * @date 2022-05-29 09:57
 */
@Slf4j
public class ByteBufferDemo {

    public static void main(String[] args) {
        ByteBuffer byteBuffer = ByteBuffer.allocate(256);
        System.out.println("ByteBuffer.limit: " + byteBuffer.limit());
        System.out.println("ByteBuffer.capacity: " + byteBuffer.capacity());
        System.out.println("ByteBuffer.position: " + byteBuffer.position());

        byteBuffer.put("abcdefg".getBytes(StandardCharsets.UTF_8));
        System.out.println("ByteBuffer.position after put \"abcdefg\": " + byteBuffer.position());


    }
}
